package part05_原型模式.p02_原型模式解决克隆羊;

/**
 * @ClassName: ClientClone02
 * @Author: AllenSun
 * @Date: 2019/12/6 20:56
 */
public class ClientClone02 {
    public static void main(String[] args) {
        System.out.println("原型模式完成对象的创建");
        Sheep02 sheep = new Sheep02("tom",1,"白色");
        sheep.friend=new Sheep02("jack",2,"黑色");

        Sheep02 sheep02=(Sheep02)sheep.clone();
        Sheep02 sheep03=(Sheep02)sheep.clone();
        Sheep02 sheep04=(Sheep02)sheep.clone();
        Sheep02 sheep05=(Sheep02)sheep.clone();
        Sheep02 sheep06=(Sheep02)sheep.clone();

        System.out.println("sheep02="+sheep02+",sheep02's friend="+sheep02.friend.hashCode());
        System.out.println("sheep03="+sheep03+",sheep03's friend="+sheep03.friend.hashCode());
        System.out.println("sheep04="+sheep04+",sheep04's friend="+sheep04.friend.hashCode());
    }
}
